//
//  AFNetWorkingWrapper.m
//  SmartCity
//
//  Created by csc on 14/12/23.
//  Copyright (c) 2014年 com.SmartCity. All rights reserved.
//

#import "AFNetWorkingWrapper.h"

@implementation AFNetWorkingWrapper


//
//#pragma mark - 检测网络连接
//+ (void)startMonitorNetWorkStatus:(void (^)(AFNetworkReachabilityStatus status))block
//{
//    /**
//     AFNetworkReachabilityStatusUnknown          = -1,  // 未知
//     AFNetworkReachabilityStatusNotReachable     = 0,   // 无连接
//     AFNetworkReachabilityStatusReachableViaWWAN = 1,   // 3G 花钱
//     AFNetworkReachabilityStatusReachableViaWiFi = 2,   // 局域网络,不花钱
//     */
//    // 如果要检测网络状态的变化,必须用检测管理器的单例的startMonitoring
//    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
//    
////    // 检测网络连接的单例,网络变化时的回调方法
////    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
////        NSLog(@"%d", status);
////    }];
//
//    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:block];
//}
//
//
//
//+ (void)PostAndAcceptJson:(NSDictionary *)dict URL:(NSString *)url
//                  Success:(void (^)(AFHTTPRequestOperation *operation,id jsonObject))success
//                  Failure:(void(^)(AFHTTPRequestOperation *operation,NSError *error))fail;
//{
//    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
//    
//
//    // 设置请求格式
//    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
//    // 设置返回Json格式
//    mgr.responseSerializer = [AFJSONResponseSerializer serializer]; //AFJSONResponseSerializer : json, AFHTTPResponseSerializer: NSData
//    mgr.requestSerializer.timeoutInterval = 12;
//    
//    if ( [UserInfoManager isLoged] )
//    {
//        NSString* tokenString = [UserInfoManager sharedInstance].token;
//        if (tokenString)
//        {
//            NSString* userId = [UserInfoManager sharedInstance].userId;
//            //Authorization
//            [mgr.requestSerializer setValue:tokenString forHTTPHeaderField:@"token"];
//            [mgr.requestSerializer setValue:userId forHTTPHeaderField:@"userId"];
//        }
//    }
//    
//    [mgr POST:url parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        if (responseObject) {
//            success(operation,responseObject);
//        }
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        if (error) {
//            fail(operation,error);
//        }
//    }];
//}
//
//+ (void)PostJson:(NSDictionary *)dict URL:(NSString *)url
//         Success:(void (^)(AFHTTPRequestOperation *operation,id responseObject))success
//         Failure:(void(^)(AFHTTPRequestOperation *operation,NSError *error))fail
//{
//    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
//    // 设置请求格式
//    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
//    // 设置返回NSData格式,自己解析
//    mgr.responseSerializer = [AFHTTPResponseSerializer serializer];
//    mgr.requestSerializer.timeoutInterval = 12;
//    
//    [mgr POST:url parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        if (responseObject) {
//            success(operation,responseObject);
//        }
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        if (error) {
//            fail(operation,error);
//        }
//    }];
//}
//
//+ (void)GetJson:(NSDictionary *)dict URL:(NSString *)strUrl  Success:(void (^)(AFHTTPRequestOperation *operation,id responseObject))success
//        Failure:(void(^)(AFHTTPRequestOperation *operation,NSError *error))fail
//{
//    
//    AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
//    // 设置请求格式
//    mgr.requestSerializer = [AFJSONRequestSerializer serializer];
//    mgr.responseSerializer = [AFJSONResponseSerializer serializer];
//    mgr.requestSerializer.timeoutInterval = 12;
//    [mgr GET:strUrl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        if (responseObject) {
//            NSData *data = responseObject;
//            NSString *strData=  [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
//            
//            success(operation,strData);
//        }
//    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
//        if (error) {
//            fail(operation,error);
//        }
//    }];
//
//}


@end
